using System;
using System.Collections;

using NUnit.Framework;

namespace LocalBoard.Persistence.Test
{
	/// <summary>
	/// Summary description for TestClubCategoryAccessor.
	/// </summary>
	[TestFixture]
	public class TestClubCategoryAccessor
	{
		private IClubCategoryAccessor _unitUnderTest = null;
		private IAccessorFactory _accessorFactory = null;

		[SetUp]
		public void SetUp()
		{
			_accessorFactory = new MockAccessorFactory();
			_unitUnderTest = _accessorFactory.GetClubCategoryAccessor();
		}
		[TearDown]
		public void TearDown()
		{
			MockAccessorFactory.ResetDataTable();
			_accessorFactory = null;
			_unitUnderTest = null;
		}

		[Test]
		public void testInsertAndGetAllClubCategories()
		{
			int clubCategoryId = _unitUnderTest.Insert("testCategory");
			Hashtable allCategories = _unitUnderTest.GetAllClubCategories();
			Assert.AreEqual(2, allCategories.Count); //including administrative default category
			Assert.AreEqual("testCategory", allCategories[clubCategoryId].ToString());
		}

		[Test]
		public void testDelete()
		{
			int clubCategoryId = _unitUnderTest.Insert("testCategory");
			int clubCategoryId2 = _unitUnderTest.Insert("testCategory2");
			_unitUnderTest.Delete(clubCategoryId2);
			Hashtable allCategories = _unitUnderTest.GetAllClubCategories();
			Assert.AreEqual(2, allCategories.Count);
		}

		[Test]
		public void test()
		{
			int clubCategoryId = _unitUnderTest.Insert("testCategory");
			_unitUnderTest.Update("updatedCategoryName", clubCategoryId);
			Hashtable allCategories = _unitUnderTest.GetAllClubCategories();
			Assert.AreEqual("updatedCategoryName", allCategories[clubCategoryId].ToString());
		}
	}
}
